{% extends "crawlermanage/index.html" %}
{% block head %}
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>爬虫后台管理系统</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.6 -->
<link rel="stylesheet" href="../../static/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="../../static/style/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="../../static/plugins/iCheck/flat/blue.css">
<link rel="stylesheet" href="../../static/plugins/datatables/dataTables.bootstrap.css">
<link rel="stylesheet" href="../../static/plugins/daterangepicker/daterangepicker.css">
<link rel="stylesheet" href="../../static/plugins/select2/select2.min.css">
<link rel="stylesheet" href="../../static/dist/css/AdminLTE.min.css">
<link rel="stylesheet" href="../../static/dist/css/skins/_all-skins.min.css">
<meta charset="UTF-8">
<title>ECharts map Demo</title>
<style>

.col-center-block {
     float: none;
     display: block;
     margin-left: auto;
     margin-right: auto;
}

</style>
</head>
{% endblock %}
{% block sidebar %}
       <ul class="sidebar-menu">
        <li class="header">主控面板</li>
        <li>
          <a href="{% url 'tasks' %}">
            <i class="fa fa-dashboard"></i> <span>爬虫状态</span>
          </a>
        </li>
        <li>
          <a href="{%url 'layout'%}">
            <i class="fa fa-tasks"></i> <span>布置任务</span>
            <!-- <span class="pull-right-container">
              <small class="label pull-right bg-green">new</small>
            </span> -->
          </a>
        </li>
          <li>
          <a href="{% url 'machinelist' %}">
            <i class="fa fa-medium"></i> <span>从机管理</span>
          </a>
        </li>
        <li>
          <a href="{% url 'processlist' %}">
            <i class="fa fa-th-large"></i> <span>进程管理</span>
          </a>
        </li>
           <li class="treeview">
          <a href="#">
            <i class="fa fa-sort-alpha-asc"></i> <span>自动结构</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="{%url 'extractsinger' %}"><i class="fa fa-circle-o"></i>正文抽取</a></li>
            <li><a href="{%url 'extractmultiple' %}"><i class="fa fa-circle-o"></i>批量抽取</a></li>
          </ul>
        </li>
        <li class="active treeview">
          <a href="#">
            <i class="fa fa-map-o"></i> <span>正文测试</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="{%url 'extractarticle' %}"><i class="fa fa-circle-o"></i>批量抽取</a></li>
            <li><a href="{%url 'testarticles' %}"><i class="fa fa-circle-o"></i>批量测试</a></li>
          <li class="active"><a href="{%url 'testsingle' %}"><i class="fa fa-circle-o"></i>单例测试</a ></li>
          </ul>
        </li>
        <li>
          <a href="{% url 'charts' %}">
            <i class="fa fa-pie-chart"></i> <span>数据统计</span>
          </a>
        </li>
        <li>
          <a href="{% url 'introduce'%}">
            <i class="fa fa-book"></i> <span>使用说明</span>
          </a>
        </li>

        <li>
          <a href="{% url 'settings' %}">
            <i class="fa fa-cog"></i> <span>系统设置</span>
          </a>
        </li>
      </ul>
{% endblock %}
{% block maincontent %}
<div class="row">
    <div class="col-xs-12">
      <div class="box box-primary">

        <div class="box-header">
          <h4>单例测试</h4>
        </div>
        <!-- /.box-header -->

        <div class="box-body table-responsive">


          <div>
          <table class="table table-bordered" style="">
              <tbody>
                <tr>
                  <td>
                    <div class="form-group">
                      <label>准确文件</label>
                      <input id="standard_file"  type="text" class="form-control" placeholder="文件路径">


                    </div>
                  </td>
                  <td>
                    <label>测试文件</label>
                      <input id="test_file"  type="text" class="form-control" placeholder="文件路径">


                  </td>
                </tr>

              </tbody>

          </table>
          <span id="finished" style="color: red;display: none">路径输入有误</span>
          </div>

          <div id="mergely-resizer" style="margin-top: 30px;">
                <div id="compare"></div>
          </div>
        <!-- /.box-body -->
        </div>

          <div class="box-footer">
            <button id="submit" type="button" class="btn btn-primary pull-right" onclick="test()">测试</button>
          </div>
        <!-- /.box -->
      </div>
  </div>
</div>
			    <!-- row -->
{% endblock %}

{% block script %}

<script src="../../static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="../../static/bootstrap/js/bootstrap.min.js"></script>
<script src="../../static/dist/js/app.min.js"></script>
<script src="../../static/dist/js/demo.js"></script>
<script src="../../static/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../../static/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script src="../../static/plugins/select2/select2.full.min.js"></script>
<script src="../../static/plugins/bootstrap3-editable/js/moment.js"></script>


	<!-- Requires CodeMirror -->
<script type="text/javascript" src="../../static/plugins/mergely/lib/codemirror.js"></script>
<link type="text/css" rel="stylesheet" href="../../static/plugins/mergely/lib/codemirror.css" />

<!-- Requires Mergely -->
<script type="text/javascript" src="../../static/plugins/mergely/lib/mergely.js"></script>
<link type="text/css" rel="stylesheet" href="../../static/plugins/mergely/lib/mergely.css" />
<script type="text/javascript">
    $(document).ready(function () {
        $('#compare').mergely({
            cmsettings: { readOnly: true, lineWrapping: true},
            editor_width:'48%',
            lhs: function(setValue) {
                setValue('the quick red fox\njumped over the hairy dog');
            },
            rhs: function(setValue) {
                setValue('the quick brown fox\njumped over the lazy dog');
            }
        });
    });
    function test(){
        var standard_file = $('#standard_file').val();
        var test_file = $('#test_file').val();
        if(standard_file =='' || test_file=='') {
          alert('输入不能为空');
          return;
        }
        $.post('/crawlermanage/testsingle/', {standard_file:standard_file, test_file:test_file}, function(data) {
        // $('#test_pre').css('display','none');
        if(data!=null) {
          if(data['error']=='error'){
            $("#finished").css('display','');
          } else {
            alert(data['test'])
            $("#finished").css('display','none');
            $('#compare').mergely("lhs", data['standard'])
            $('#compare').mergely("rhs", data['test'])
          }
 
        }
    }, 'json');
        
    }

    
</script>
{% endblock %}